<html>
<head><meta charset="utf-8"><title>round_up and div_round_up · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html">round_up and div_round_up</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="194498558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194498558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194498558">(Apr 17 2020 at 20:54)</a>:</h4>
<p>I would be interested in adding methods for integer types, which round up to the next multiple of a given number, or which divide by a given number rounding up to the next multiple. For example:</p>
<p>These would look like this:</p>
<div class="codehilite"><pre><span></span><span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">0</span><span class="k">u64</span><span class="p">.</span><span class="n">div_round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">1</span><span class="k">u64</span><span class="p">.</span><span class="n">div_round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">4095</span><span class="k">u64</span><span class="p">.</span><span class="n">div_round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">4096</span><span class="k">u64</span><span class="p">.</span><span class="n">div_round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">1</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">4097</span><span class="k">u64</span><span class="p">.</span><span class="n">div_round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">2</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">8191</span><span class="k">u64</span><span class="p">.</span><span class="n">div_round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">2</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">8192</span><span class="k">u64</span><span class="p">.</span><span class="n">div_round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">2</span><span class="p">);</span><span class="w"></span>

<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">0</span><span class="k">u64</span><span class="p">.</span><span class="n">round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">1</span><span class="k">u64</span><span class="p">.</span><span class="n">round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">4096</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">4095</span><span class="k">u64</span><span class="p">.</span><span class="n">round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">4096</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">4096</span><span class="k">u64</span><span class="p">.</span><span class="n">round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">4096</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">4097</span><span class="k">u64</span><span class="p">.</span><span class="n">round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">8192</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">8191</span><span class="k">u64</span><span class="p">.</span><span class="n">round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">8192</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="mi">8192</span><span class="k">u64</span><span class="p">.</span><span class="n">round_up</span><span class="p">(</span><span class="mi">4096</span><span class="p">),</span><span class="w"> </span><span class="mi">8192</span><span class="p">);</span><span class="w"></span>
</pre></div>


<p>Does that seem reasonable? I see these operations open-coded quite often, and often incorrectly (not accounting for 0 or for overflow).</p>



<a name="194498592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194498592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194498592">(Apr 17 2020 at 20:54)</a>:</h4>
<p>Is this the kind of thing that needs an RFC, or is this something for which a PR would suffice?</p>



<a name="194498740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194498740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194498740">(Apr 17 2020 at 20:55)</a>:</h4>
<p>PR would suffice I think</p>



<a name="194517083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194517083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194517083">(Apr 18 2020 at 00:42)</a>:</h4>
<p>I've personally been using this trait in my codebase:</p>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">BitOps</span>: <span class="nb">Sized</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">BITS</span>: <span class="kt">u32</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">sign_extend</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">width</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">zero_extend</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">width</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">fits_in_bits_signed</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">width</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">fits_in_bits_unsigned</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">width</span>: <span class="kt">u32</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">is_aligned</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">align</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">align_up</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">align</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">wrapping_align_up</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">align</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">checked_align_up</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">align</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Option</span><span class="o">&lt;</span><span class="n">Self</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">align_down</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">align</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">align_offset</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">align</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="194517150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194517150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194517150">(Apr 18 2020 at 00:43)</a>:</h4>
<p>But it feels a bit niche for the standard library. The sign/zero extension stuff is mainly for dealing with instruction encodings, and the align stuff is for dealing with page alignment.</p>



<a name="194517544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194517544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194517544">(Apr 18 2020 at 00:50)</a>:</h4>
<p>The alignment stuff might fit well into Layout, or pointers, perhaps? But I agree that seems a bit more esoteric.</p>
<p>The division stuff is more widely applicable I think</p>



<a name="194518595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194518595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194518595">(Apr 18 2020 at 01:11)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> Note that on ARM, the page size is not a compile-time constant (though on most systems it is 4K). The proper way of getting the page size on Linux is to read <code>getauxval(AT_PAGESZ)</code>. However now the compiler can't know that it is a power of two and will have to generate a division instruction instead of a faster bitwise masking.</p>



<a name="194518689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194518689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194518689">(Apr 18 2020 at 01:12)</a>:</h4>
<p>Wait, you can't assume it's a power of two?</p>



<a name="194518754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194518754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194518754">(Apr 18 2020 at 01:14)</a>:</h4>
<p>You can, but the problem is that the compiler doesn't know that. So it can't optimize the divide to a mask.</p>



<a name="194518760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194518760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194518760">(Apr 18 2020 at 01:14)</a>:</h4>
<p>Hence why I went with <code>align_*</code> instead of <code>divide_round_*</code>.</p>



<a name="194518949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194518949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194518949">(Apr 18 2020 at 01:19)</a>:</h4>
<p>I will note that there's lots of cases where I've wanted division with rounding that isn't related to page size and such, including non-power-of-two cases</p>



<a name="194518954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194518954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194518954">(Apr 18 2020 at 01:19)</a>:</h4>
<p>well maybe "lots" is an exaggeration :) but certainly not one</p>



<a name="194526418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194526418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194526418">(Apr 18 2020 at 05:00)</a>:</h4>
<p>I currently have a codebase that involves many calls to (a locally defined version of) <code>round_up</code> and <code>div_round_up</code>, many of which are powers of two but not all, and most of which are not the page size.</p>



<a name="194565701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194565701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194565701">(Apr 18 2020 at 21:58)</a>:</h4>
<p>num-integer calls these <code>div_ceil</code> and <code>next_multiple_of</code></p>



<a name="194579121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194579121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194579121">(Apr 19 2020 at 04:51)</a>:</h4>
<p><code>next_multiple_of</code> seems like a clearer name than <code>round_up</code>. But I've seen <code>div_round_up</code> used pretty widely, and I think it's clearer than <code>div_ceil</code>.</p>



<a name="194585957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194585957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194585957">(Apr 19 2020 at 08:27)</a>:</h4>
<p>I'd use these in Miri immediately :D</p>



<a name="194585999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194585999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194585999">(Apr 19 2020 at 08:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/219381-t-libs/topic/round_up.20and.20div_round_up/near/194579121" title="#narrow/stream/219381-t-libs/topic/round_up.20and.20div_round_up/near/194579121">said</a>:</p>
<blockquote>
<p><code>next_multiple_of</code> seems like a clearer name than <code>round_up</code>. But I've seen <code>div_round_up</code> used pretty widely, and I think it's clearer than <code>div_ceil</code>.</p>
</blockquote>
<p>I also thought <code>round_up</code> and <code>div_round_up</code> would be very similar given their name, but I think they actually aren't... so <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> for renaming one of them</p>



<a name="194600264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194600264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194600264">(Apr 19 2020 at 14:26)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> If you'd use these in miri, that's a good argument for including them.</p>



<a name="194600935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194600935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194600935">(Apr 19 2020 at 14:42)</a>:</h4>
<p>to be precise, I'd use <code>next_multiple_of</code>:<br>
<a href="https://github.com/rust-lang/miri/blob/4155fb610fca4fe38348ae9c57931450d7bc95d7/src/intptrcast.rs#L128" title="https://github.com/rust-lang/miri/blob/4155fb610fca4fe38348ae9c57931450d7bc95d7/src/intptrcast.rs#L128">https://github.com/rust-lang/miri/blob/4155fb610fca4fe38348ae9c57931450d7bc95d7/src/intptrcast.rs#L128</a></p>



<a name="194600987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194600987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194600987">(Apr 19 2020 at 14:43)</a>:</h4>
<p><code>div_round_up</code> has certainly come up in code I wrote before, so I'm all for it, but I don't think miri would benefit</p>



<a name="194608781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194608781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194608781">(Apr 19 2020 at 17:23)</a>:</h4>
<p>it's subjective, but I like the name <code>div_ceil</code> because it's close to what you'd write for floating point, <code>(x / y).ceil()</code></p>



<a name="194626633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/round_up%20and%20div_round_up/near/194626633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/round_up.20and.20div_round_up.html#194626633">(Apr 20 2020 at 01:29)</a>:</h4>
<p>had occasion to use a div_and_round_up style operation myself today</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>